package com.sxp.model;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * Created by lakmini on 10/27/14.
 */
public class Month {
    private int year;
    private String month;
    private int maxDay;


    public Month(int year, String month, int maxDay) {
        this.year = year;
        this.month = month;
        this.maxDay = maxDay;
    }

    public Month() {
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public String getMonth() {
        return month;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public int getMaxDay() {
        return maxDay;
    }

    public void setMaxDay(int maxDay) {
        this.maxDay = maxDay;
    }

    public String getCurrentMonth(){
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM");
        String curMonthName=dateFormat.format(cal.getTime());
        return curMonthName;

    }
    public int getCurrentYear(){
        Calendar cal = Calendar.getInstance();
        int currentYear = cal.get(Calendar.YEAR);
        return currentYear;
    }

    public int getCurrentMonthMaximumDays(){
        Calendar cal = Calendar.getInstance();
        int maxDay =cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        return maxDay;
    }

    public int getPreviousMonthMaximumDays(){
        Calendar cal = Calendar.getInstance();
        int thisYear= cal.get(Calendar.YEAR);
        int thisMonth = cal.get(Calendar.MONTH);

        if(thisMonth==cal.get(Calendar.JANUARY)){
            cal.set(thisYear-1,Calendar.DECEMBER,1);
        }
        else{
            cal.set(thisYear,thisMonth-1,1);
        }


        int maxDay =cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        return maxDay;
    }

    public int getNextMonthMaximumDays(){
        Calendar cal = Calendar.getInstance();
        int thisYear= cal.get(Calendar.YEAR);
        int thisMonth = cal.get(Calendar.MONTH);

        if(thisMonth==cal.get(Calendar.DECEMBER)){
            cal.set(thisYear+1,Calendar.JANUARY,1);
        }
        else{
            cal.set(thisYear,thisMonth+1,1);
        }

        int maxDay =cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        return maxDay;
    }

}
